home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / turbotut.arc / LOOPDEMO.PAS < prev    next >
Pascal/Delphi Source File  |  1989-06-30  |  741b  |  37 lines

  1. PROGRAM demonstrate_loops;
  2.  
  3. VAR count  : INTEGER;
  4.     start  : INTEGER;
  5.     ending : INTEGER;
  6.     total  : INTEGER;
  7.     alphabet : CHAR;
  8.  
  9. BEGIN
  10.   start := 1;
  11.   ending := 7;
  12.   FOR count := start TO ending DO      (* Example 1 *)
  13.     WRITELN('This is a count loop and we are in pass',count:4);
  14.  
  15.   total := 0;
  16.   FOR count := 1 TO 10 DO              (* Example 2 *)
  17.   BEGIN
  18.     total := total + 12;
  19.     WRITE('count =',count:3,'  total =',total:5);
  20.     WRITELN;
  21.   END;
  22.  
  23.   WRITELN;
  24.   WRITE('The alphabet is ');
  25.   FOR alphabet := 'A' TO 'Z' DO         (* Example 3 *)
  26.     WRITE(alphabet);
  27.   WRITELN;
  28.  
  29.   FOR count := 7 DOWNTO 2 DO            (* Example 4 *)
  30.     WRITELN('Decrementing loop ',count:3);
  31.  
  32. END.
  33.  
  34.  
  35.  
  36.  
  37.